<!doctype html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>深入理解存储过程与MyBatis集成</title>
    <link rel="stylesheet" href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css">
    <link rel="stylesheet" href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
            min-height: 100vh;
        }
        
        .hero-gradient {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            position: relative;
            overflow: hidden;
        }
        
        .hero-gradient::before {
            content: '';
            position: absolute;
            top: -50%;
            right: -50%;
            bottom: -50%;
            left: -50%;
            background: radial-gradient(circle, rgba(255,255,255,0.1) 1px, transparent 1px);
            background-size: 50px 50px;
            animation: drift 20s linear infinite;
        }
        
        @keyframes drift {
            from { transform: translate(0, 0); }
            to { transform: translate(50px, 50px); }
        }
        
        .content-card {
            background: rgba(255, 255, 255, 0.95);
            backdrop-filter: blur(10px);
            box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
            transition: all 0.3s ease;
        }
        
        .content-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 25px 50px rgba(0, 0, 0, 0.15);
        }
        
        .section-title {
            position: relative;
            padding-left: 20px;
        }
        
        .section-title::before {
            content: '';
            position: absolute;
            left: 0;
            top: 50%;
            transform: translateY(-50%);
            width: 4px;
            height: 80%;
            background: linear-gradient(180deg, #667eea 0%, #764ba2 100%);
            border-radius: 2px;
        }
        
        .code-block {
            background: #1e1e1e;
            color: #d4d4d4;
            border-radius: 12px;
            padding: 24px;
            overflow-x: auto;
            position: relative;
            font-family: 'Consolas', 'Monaco', monospace;
        }
        
        .code-block::before {
            content: attr(data-lang);
            position: absolute;
            top: 10px;
            right: 15px;
            font-size: 12px;
            color: #858585;
            text-transform: uppercase;
            letter-spacing: 1px;
        }
        
        .advantage-card {
            background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
            color: white;
            padding: 20px;
            border-radius: 12px;
            transition: all 0.3s ease;
            position: relative;
            overflow: hidden;
        }
        
        .advantage-card::before {
            content: '';
            position: absolute;
            top: -50%;
            right: -50%;
            width: 200%;
            height: 200%;
            background: radial-gradient(circle, rgba(255,255,255,0.2) 0%, transparent 70%);
            transition: all 0.5s ease;
            opacity: 0;
        }
        
        .advantage-card:hover::before {
            opacity: 1;
        }
        
        .advantage-card:hover {
            transform: scale(1.05);
            box-shadow: 0 15px 30px rgba(0, 0, 0, 0.2);
        }
        
        .step-number {
            width: 40px;
            height: 40px;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            font-weight: bold;
            font-size: 18px;
            flex-shrink: 0;
        }
        
        .mermaid {
            background: white;
            padding: 20px;
            border-radius: 12px;
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
        }
        
        .highlight-text {
            background: linear-gradient(120deg, #f093fb 0%, #f5576c 100%);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            background-clip: text;
            font-weight: 600;
        }
        
        .floating-icon {
            animation: float 3s ease-in-out infinite;
        }
        
        @keyframes float {
            0%, 100% { transform: translateY(0); }
            50% { transform: translateY(-10px); }
        }
    </style>
</head>
<body>
    <!-- Hero Section -->
    <section class="hero-gradient text-white py-20 relative">
        <div class="container mx-auto px-6 relative z-10">
            <div class="text-center">
                <div class="floating-icon inline-block mb-6">
                    <i class="fas fa-database text-6xl opacity-90"></i>
                </div>
                <h1 class="text-5xl md:text-6xl font-bold mb-6 tracking-tight">
                    深入理解<span class="text-yellow-300">存储过程</span>
                </h1>
                <p class="text-xl md:text-2xl mb-8 opacity-90 max-w-3xl mx-auto leading-relaxed">
                    探索数据库存储过程的强大功能，掌握MyBatis框架的高级集成技巧
                </p>
                <div class="flex justify-center space-x-4">
                    <span class="bg-white bg-opacity-20 px-4 py-2 rounded-full text-sm">
                        <i class="fas fa-clock mr-2"></i>阅读时间：8分钟
                    </span>
                    <span class="bg-white bg-opacity-20 px-4 py-2 rounded-full text-sm">
                        <i class="fas fa-tag mr-2"></i>数据库优化
                    </span>
                </div>
            </div>
        </div>
    </section>

    <!-- Main Content -->
    <main class="container mx-auto px-6 py-12">
        <!-- 什么是存储过程 -->
        <section class="mb-16">
            <div class="content-card rounded-2xl p-8 md:p-12">
                <h2 class="section-title text-3xl font-bold mb-6 text-gray-800">
                    <i class="fas fa-question-circle mr-3 text-purple-600"></i>
                    存储过程是什么？
                </h2>
                <p class="text-lg leading-relaxed text-gray-700 mb-6">
                    存储过程是能完成一定操作的一组SQL语句，它在创建后可以被有权用户在任何需要的地方调用。通过使用过程，不仅可以简化客户端应用程序的开发和维护，而且可以提高应用程序的运行性能。
                </p>
                <div class="bg-purple-50 border-l-4 border-purple-500 p-6 rounded-r-lg">
                    <p class="text-gray-700">
                        <i class="fas fa-lightbulb text-purple-600 mr-2"></i>
                        <strong>实际应用场景：</strong>假如某应用程序需要经常向某张表中插入数据，并且在插入数据时需要对数据进行检查验证，为了简化客户端的维护，可以使用存储过程。
                    </p>
                </div>
            </div>
        </section>

        <!-- 存储过程的优势 -->
        <section class="mb-16">
            <div class="content-card rounded-2xl p-8 md:p-12">
                <h2 class="section-title text-3xl font-bold mb-8 text-gray-800">
                    <i class="fas fa-star mr-3 text-purple-600"></i>
                    存储过程的优势
                </h2>
                <div class="grid md:grid-cols-3 gap-6">
                    <div class="advantage-card">
                        <i class="fas fa-rocket text-3xl mb-4"></i>
                        <h3 class="text-xl font-bold mb-3">一次编译，多次执行</h3>
                        <p>存储过程保存在MySQL中，只需要编译一次就可以了，调用时直接执行，大幅提升性能。</p>
                    </div>
                    <div class="advantage-card">
                        <i class="fas fa-cogs text-3xl mb-4"></i>
                        <h3 class="text-xl font-bold mb-3">复杂业务逻辑处理</h3>
                        <p>一些复杂的操作和业务逻辑代码可以放在存储过程里面运行，性能会更高。</p>
                    </div>
                    <div class="advantage-card">
                        <i class="fas fa-tachometer-alt text-3xl mb-4"></i>
                        <h3 class="text-xl font-bold mb-3">减少重复编译</h3>
                        <p>相比SQL语句在项目中调用10次需要编译10次，存储过程避免了重复编译的开销。</p>
                    </div>
                </div>
            </div>
        </section>

        <!-- 概念关系图 -->
        <section class="mb-16">
            <div class="content-card rounded-2xl p-8 md:p-12">
                <h2 class="section-title text-3xl font-bold mb-8 text-gray-800">
                    <i class="fas fa-project-diagram mr-3 text-purple-600"></i>
                    存储过程工作流程
                </h2>
                <div class="mermaid">
                    graph LR
                        A[客户端应用] -->|调用| B[MyBatis框架]
                        B -->|执行| C[存储过程]
                        C -->|访问| D[数据库表]
                        D -->|返回结果| C
                        C -->|输出参数| B
                        B -->|映射结果| A
                        
                        style A fill:#667eea,stroke:#fff,stroke-width:2px,color:#fff
                        style B fill:#764ba2,stroke:#fff,stroke-width:2px,color:#fff
                        style C fill:#f093fb,stroke:#fff,stroke-width:2px,color:#fff
                        style D fill:#f5576c,stroke:#fff,stroke-width:2px,color:#fff
                </div>
            </div>
        </section>

        <!-- MyBatis调用存储过程 -->
        <section class="mb-16">
            <div class="content-card rounded-2xl p-8 md:p-12">
                <h2 class="section-title text-3xl font-bold mb-8 text-gray-800">
                    <i class="fas fa-code mr-3 text-purple-600"></i>
                    MyBatis调用存储过程
                </h2>
                <p class="text-lg leading-relaxed text-gray-700 mb-8">
                    MyBatis框架支持调用存储过程来执行数据库操作。存储过程是一组预编译的SQL语句集合，可以在数据库中进行存储和调用。
                </p>
                
                <!-- 步骤说明 -->
                <div class="space-y-6 mb-10">
                    <div class="flex items-start space-x-4">
                        <div class="step-number">1</div>
                        <div class="flex-1">
                            <h3 class="text-xl font-semibold mb-2">在数据库中创建存储过程</h3>
                            <p class="text-gray-600">首先需要在数据库中定义存储过程，包括输入参数、输出参数和具体的SQL逻辑。</p>
                        </div>
                    </div>
                    <div class="flex items-start space-x-4">
                        <div class="step-number">2</div>
                        <div class="flex-1">
                            <h3 class="text-xl font-semibold mb-2">在Mapper XML中定义调用语句</h3>
                            <p class="text-gray-600">在MyBatis的Mapper XML文件中定义调用存储过程的SQL语句，指定参数模式。</p>
                        </div>
                    </div>
                    <div class="flex items-start space-x-4">
                        <div class="step-number">3</div>
                        <div class="flex-1">
                            <h3 class="text-xl font-semibold mb-2">在Java代码中调用</h3>
                            <p class="text-gray-600">通过MyBatis的接口方法，在Java代码中执行存储过程并获取结果。</p>
                        </div>
                    </div>
                </div>

                <!-- 示例代码 -->
                <div class="bg-gray-50 rounded-xl p-6 mb-8">
                    <h3 class="text-2xl font-bold mb-6 text-gray-800">
                        <i class="fas fa-laptop-code mr-2 text-purple-600"></i>
                        完整示例演示
                    </h3>
                    
                    <!-- Step 1: 创建存储过程 -->
                    <div class="mb-8">
                        <h4 class="text-lg font-semibold mb-3 flex items-center">
                            <span class="bg-purple-600 text-white rounded-